﻿using EquipmentAlarmSystem.Service.ContentPushUnit;
using EquipmentAlarmSystem.Service.Models.Enum;
using Microsoft.AspNetCore.Mvc;

namespace EquipmentAlarmSystem.Controllers;

/// <summary>
/// 发送
/// </summary>
[ApiController]
[Route("[controller]/[action]")]
public class AlarmSendingController : Controller
{
    private readonly ILogger<AlarmSendingController> _logger;

    public AlarmSendingController(ILogger<AlarmSendingController> logger)
    {
        _logger = logger;
    }

    /// <summary>
    /// 获取短信报警器状态
    /// </summary>
    /// <returns></returns>
    [HttpGet]
    public bool GetSmsAlarmStatus()
    {
        return SmsAlarmConnection.AlarmStatus;
    }

    /// <summary>
    /// 发送短信
    /// </summary>
    /// <returns></returns>
    [HttpPost]
    public string SendSms(SendingMessages sending)
    {
        //获取报警状态
        InformationPushService.Add(MessageType.Sms, new List<string>() { sending.To }, sending.Content);
        return "任务已添加";
    }

    /// <summary>
    ///拨打电话
    /// </summary>
    /// <returns></returns>
    [HttpPost]
    public string MakingPhoneCalls(SendingMessages sending)
    {
        //获取报警状态
        InformationPushService.Add(MessageType.Call, new List<string>() { sending.To }, sending.Content);
        return "任务已添加";
    }
}

/// <summary>
/// 发送信息
/// </summary>
public class SendingMessages()
{
    public MessageType MsgType { get; set; }

    public string To { get; set; }

    public string Content { get; set; }
}
